<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>物流展示页面</title>

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <!-- 引入bootstarp -->
    <script type="text/javascript" src="../js/bootstrap3/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.css">
    <!-- 引入bootstrap table的css、js -->
    <link type="text/css" rel="stylesheet" href="../js/bootstrap-table/bootstrap-table.css">
    <script type="text/javascript" src="../js/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="../js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
    <!-- 引入bootstrap datetime的css、js -->
    <link type="text/css" rel="stylesheet" href="../js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css">
    <script type="text/javascript" src="../js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="../js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <!-- 引入bootstrap bootbox的css、js -->
    <script type="text/javascript" src="../js/bootstrap-bootbox/bootbox.js"></script>

</head>
<body>
<form class="form-inline">
    <div class="form-group">
        <label for="username">
            <font color="#adff2f">用户名</font>
        </label>
        <input type="text" class="form-control" id="userName" placeholder="请输入名字">
        <label for="startTime">
            <font color="#adff2f">时间</font>
        </label>
        <input type="text" class="date form-control" id="startTime" placeholder="请输入开始时间">
        <i class="glyphicon glyphicon-calendar"></i>
        <input type="text" class="date form-control" id="endTime" placeholder="请输入结束时间">
    </div>
    <button type="button" class="btn btn-primary glyphicon glyphicon-search" onclick="searchUser()">搜索</button>
    <button type="button" class="btn btn-danger glyphicon glyphicon-remove" onclick="delUser()">删除</button>



</form>
<div id="bookTable"></div>

</body>
<script>
    $(function(){

        initMyTable();


    })
    /**
     * 查询
     * */
    function initMyTable(){
        $('#bookTable').bootstrapTable({
            url:'../cjq/findwuliuList',//获取数据地址
            method:'post',
            contentType:'application/x-www-form-urlencoded',//post请求按照表单方式
            pagination:true, //是否展示分页
            pageList:[2, 4, 6, 8],//分页组件
            pageNumber:1,
            pageSize:2,//默认每页条数
            clickToSelect: true, //是否启用点击选中行
            sidePagination:'server',//分页方式：client客户端分页，server服务端分页（*
            striped:true,
            queryParams:function(){

                return {

                    page: this.pageNumber,
                    rows: this.pageSize,
                    recipientsName:$("#userName").val(),
                    startTime:$("#startTime").val(),
                    endTime:$("#endTime").val()
                };
            },
            columns:[
                [
                    {checkbox:true},
                    {field:'id',title:'id',width:200},
                    {field:'orderName',title:'订单编号',width:200},
                    {field:'recipientsName',title:'名字',width:200},
                    {field:'userName',title:'用户id',width:200},
                    {field:'logisticsTime',title:'时间',width:200},
                    {field:'logisticsStatus',title:'是否发货',width:200,formatter:function (value,row,index){
                            if(value==1){
                                return "已发货";
                            }else if(value==2){
                                return "未发货";

                            }

                        }},
                    {field:'logisticsInfo',title:'物流信息',width:200},
                    {field:'logisticsGongsi',title:'物流公司',width:200},
                    {field:'cz',title:'操作',width:200,formatter:function (value,row,index){
                     return "<a href='javascript:deleteUser("+row.id+")'>删除</a>";
                    }
                    }
                ]
            ]
        });
    }






    /**
     * 条查
     * */
    function searchUser(){
        $("#bookTable").bootstrapTable("refresh", {
            query:{
                'page':1,


            }
        });

    }

    /**
     * 删除用户信息
     */
    function deleteUser(id) {
        $.ajax({
            url:"../cjq/delUserById",
            data:{ids:id},
            success:function(data) {
                if (data) {
                    bootbox.alert({
                            size: "small",
                            title: "提示",
                            message: "删除成功",
                            buttons: {
                                ok: {
                                    label: '确定',
                                    className: 'btn-success'
                                }
                            },
                            callback: function () {

                            }
                        }
                    )
                    searchUser();
                }
            }
        })
    }



    /**
     * 删除用户信息
     */
    function delUser(){
        var arr=$("#bookTable").bootstrapTable("getSelections");
        if(arr <= 0){
            bootbox.alert({
                size: "small",
                title: "提示",
                message: "至少选择一行",
                buttons: {
                    ok: {
                        label: '确定',
                        className: 'btn-success'
                    }
                },
                callback: function(){}
            });
        }else {
            bootbox.confirm({
                size: "small",
                title: "提示",
                message: "确定要删除吗？",
                buttons: {
                    confirm: {
                        label: '确定',
                        className: 'btn-success'
                    },
                    cancel: {
                        label: '取消',
                        className: 'btn-danger'
                    }
                },
                callback: function(result){
                    if(result){
                        var ids="";
                        for (var i = 0; i < arr.length; i++) {
                            ids+=ids==""?arr[i].id:","+arr[i].id
                        }
                        $.ajax({
                            url:"../cjq/delUserById",
                            data:{ids:ids},
                            success:function(data){
                                if(data){
                                    bootbox.alert({
                                        size: "small",
                                        title: "提示",
                                        message: "删除成功",
                                        buttons: {
                                            ok: {
                                                label: '确定',
                                                className: 'btn-success'
                                            }
                                        },
                                        callback :function(){}
                                    })
                                    searchUser()
                                }
                            }
                        })
                    }
                }
            })
        }
    }


</script>

</html>